********************************************************************************
/*

					       Replication of the results of
					 
					 "Electoral concerns reduce restrictive measures
					         during the COVID-19 pandemic"
						
							       Massimo Pulejo 
							       Pablo Querubín 

*/
********************************************************************************

                              ***** SET UP *****	

*ssc install outreg2, replace
							  
********************************************************************************
* Please, on line 24 below copy the path of the folder where you put the files *
*    covid19_replication.dta and covid19_replication.do on your own machine    *
********************************************************************************

cd "C:\Users\massi\Dropbox\COVID Response\Replication"

use covid19_replication.dta, clear





                  ***** RESULTS IN MAIN BODY OF PAPER *****	
																	 
*** TABLE 1: EFFECTS OF REELECTION CONCERNS ON STRINGENCY OF COVID-19 RESTRICTIONS ***

* Column 1: Depvar SI_1, Any Limit *
reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Any Limit) nocon tex replace

* Column 2: Depvar SI_1, Two-Term Limit *
reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Two-Term Limit) nocon tex append

* Column 3: Depvar SI_2, Any Limit *
reg SI_2 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Any Limit) nocon tex append

* Column 4: Depvar SI_2, Two-Term Limit *
reg SI_2 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Two-Term Limit) nocon tex append

* Column 5: Depvar SI_3, Any Term Limit *
reg SI_3 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Two-Term Limit) nocon tex append

* Column 6: Depvar SI_3, Any Term Limit *
reg SI_3 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
estadd ysumm
outreg2 using T1, addstat(Mean Depvar, e(ymean)) addtext(Sample, Two-Term Limit) nocon tex append



*** FIGURE 1: STRINGENCY AND YEARS TO ELECTION, BY PRESENCE OF TERM LIMITS ***

** Panel A: Leader Is Term Limited **

reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms !=., vce(robust)
qui gen in_panelA = 0
qui replace in_panelA = 1 if e(sample)==1
keep if in_panelA == 1

scatter SI_1 electionproximity_yrs if canrun == 0 || lfit SI_1 electionproximity_yrs if canrun == 0, ytitle("Average Stringency (SI1)", height(7)) xtitle("Years to Election", height(7)) title(Panel A: Leader Is Term Limited, color(black) height(3) tstyle(size(medium small))) graphregion(color(white)) ysc(r(20 100)) ylabel(20(20)100) legend(off)
graph export "C:\Users\massi\Dropbox\COVID Response\Publication_JPubE\F1_panelA.jpg", as(jpg) quality(100) name("Graph")


** Panel B: Leader Is Not Term Limited **

scatter SI_1 electionproximity_yrs if canrun == 1 || lfit SI_1 electionproximity_yrs if canrun == 1, ytitle("Average Stringency (SI1)", height(7)) xtitle("Years to Election", height(7)) title(Panel B: Leader Is Not Term Limited, color(black) height(3) tstyle(size(medium small))) graphregion(color(white)) ysc(r(20 100)) ylabel(20(20)100) legend(off)
graph export "C:\Users\massi\Dropbox\COVID Response\Publication_JPubE\F1_panelB.jpg", as(jpg) quality(100) name("Graph")



*** FIGURE 2: EFFECT BY SINGLE COMPONENTS OF THE STRINGENCY INDEX ***

** Panel A: Any Term Limit **

* Prepare empty data set to store results *

clear all
set obs 9
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
save fig2_panelA.dta, replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_c1_schools Z_c2_workplace Z_c3_publicevents Z_c4_gatherings Z_c5_publictransport Z_c6_stayhome Z_c7_internalmovement Z_c8_internationaltravel Z_h1_infocampaigns {
    
preserve
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
sleep 1000
use fig2_panelA.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig2_panelA.dta, replace
restore			
}

* Producing the plot *

use fig2_panelA.dta, clear
su pvalue coeff, d
drop if coeff==.

capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 1 "Schools" 2 "Workplaces" 3 "Events" 4 "Gatherings" ///
5 "Transportation" 6 "Stay Home" 7 "Movement" 8 "Travel" 9 "Info"
label val no example

twoway (rcap cit cib no, lcolor(navy)) ///
(scatter coeff no, msymbol(x) mcolor(navy) legend(order(1 "95% Confidence Interval" 2 "Point Estimates")) ///
xtick(1 2 3 4 5 6 7 8 9) xlabel(1 2 3 4 5 6 7 8 9, alternate valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) ysc(r(-.6 .4)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small))) ///
name(Graph, replace))
graph save Graph "F2_PanelA", replace
graph export "F2_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

* Prepare empty data set to store results *

clear all
set obs 9
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
save fig2_panelB.dta, replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_c1_schools Z_c2_workplace Z_c3_publicevents Z_c4_gatherings Z_c5_publictransport Z_c6_stayhome Z_c7_internalmovement Z_c8_internationaltravel Z_h1_infocampaigns {
    
preserve
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
sleep 1000
use fig2_panelB.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig2_panelB.dta, replace
restore			
}

* Producing the plot *

use fig2_panelB.dta, clear
su pvalue coeff, d
drop if coeff==.

capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 1 "Schools" 2 "Workplaces" 3 "Events" 4 "Gatherings" ///
5 "Transportation" 6 "Stay Home" 7 "Movement" 8 "Travel" 9 "Info"
label val no example

twoway (rcap cit cib no, lcolor(navy)) ///
(scatter coeff no, msymbol(x) mcolor(navy) legend(order(1 "95% Confidence Interval" 2 "Point Estimates")) ///
xtick(1 2 3 4 5 6 7 8 9) xlabel(1 2 3 4 5 6 7 8 9, alternate valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small))) ///
name(Graph, replace))
graph save Graph "F2_PanelB", replace
graph export "F2_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE 3: OTHER DIMENSIONS OF RESPONSE ***

** Panel A: Any Term Limit **

* Prepare empty data set to store results *

clear all
set obs 6
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Economy"
g id = _n
replace group = "Health" if id > 4
gen group_order = 1
replace group_order = 2 if group == "Health"
drop id
save fig3_panelA.dta, replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_e1_incomesupport Z_e2_debtcontractrelief Z_e3_fiscalmeasures Z_economicsupportindex Z_h2_testingpolicy Z_h3_contacttracing {
    
preserve
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
sleep 1000
use fig3_panelA.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig3_panelA.dta, replace
restore			
}

* Producing the plot *

use fig3_panelA.dta, clear
su pvalue coeff, d
drop if coeff==.

capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 1 "Income" 2 "Debt" 3 "Fiscal" 4 "Index" 5 "Test" 6 "Trace"
label val no example

twoway (rcap cit cib no if group=="Economy", lcolor(gs3)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(gs3) ///
xtick(1 2 3 4 5 6) xlabel(1 2 3 4 5 6, alternate valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Health", lcolor(gs12)) ///
(scatter coeff no if group=="Health", msymbol(x) mcolor(gs6) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates")) name(Graph, replace))
graph save Graph "F3_PanelA", replace
graph export "F3_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

* Prepare empty data set to store results *

clear all
set obs 6
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Economy"
g id = _n
replace group = "Health" if id > 4
gen group_order = 1
replace group_order = 2 if group == "Health"
drop id
save fig3_panelB.dta, replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_e1_incomesupport Z_e2_debtcontractrelief Z_e3_fiscalmeasures Z_economicsupportindex Z_h2_testingpolicy Z_h3_contacttracing {
    
preserve
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
sleep 1000
use fig3_panelB.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig3_panelB.dta, replace
restore			
}

* Producing the plot *

use fig3_panelB.dta, clear
su pvalue coeff, d
drop if coeff==.

capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 1 "Income" 2 "Debt" 3 "Fiscal" 4 "Index" 5 "Test" 6 "Trace"
label val no example

twoway (rcap cit cib no if group=="Economy", lcolor(gs3)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(gs3) ///
xtick(1 2 3 4 5 6) xlabel(1 2 3 4 5 6, alternate valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Health", lcolor(gs12)) ///
(scatter coeff no if group=="Health", msymbol(x) mcolor(gs6) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates")) name(Graph, replace))
graph save Graph "F3_PanelB", replace
graph export "F3_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE 4: BALANCE TESTS ***

** Panel A: Any Term Limit **

* Prepare empty data set to store results *

clear all
set obs 48
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Politics"
g id = _n
replace group = "Geo/Demo" if id > 12 & id < 25
replace group = "Economy" if id > 24 & id < 37  
replace group = "China" if id > 36
gen group_order = 1
replace group_order = 2 if group == "Geo/Demo"
replace group_order = 3 if group == "Economy"
replace group_order = 4 if group == "China"
drop id 
save fig4_panelA.dta  , replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 {

preserve    
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
sleep 1000
use fig4_panelA.dta , clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig4_panelA, replace
restore
}

* Producing the plot *

use fig4_panelA, clear
su pvalue coeff, d
drop if coeff==.

sort group_order coeff
capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 6 "Politics" 18 "Geo/Demo" 30 "Economy" 42 "China" 
label val no example

twoway (rcap cit cib no if group=="Politics", lcolor(black)) ///
(scatter coeff no if group=="Politics", msymbol(x) mcolor(black) ///
xtick(6 18 30 42) xlabel(6 18 30 42, alternate  valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) ysc(r(-1 .5)) title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Geo/Demo", lcolor(dkgreen)) ///
(scatter coeff no if group=="Geo/Demo", msymbol(x) mcolor(dkgreen)) ///
(rcap cit cib no if group=="Economy", lcolor(navy)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(navy)) ///
(rcap cit cib no if group=="China", lcolor(red)) ///
(scatter coeff no if group=="China", msymbol(x) mcolor(red) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates"))  name(Graph, replace))
graph save Graph "F4_PanelA", replace
graph export "F4_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

* Prepare empty data set to store results *

clear all
set obs 48
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Politics"
g id = _n
replace group = "Geo/Demo" if id > 12 & id < 25
replace group = "Economy" if id > 25 & id < 37  
replace group = "China" if id > 36
gen group_order = 1
replace group_order = 2 if group == "Geo/Demo"
replace group_order = 3 if group == "Economy"
replace group_order = 4 if group == "China"
drop id 
save fig4_panelB.dta  , replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 {
    
preserve	
eststo `var': reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
sleep 1000
use fig4_panelB.dta , clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save fig4_panelB, replace
restore			
}

* Producing the plot *

use fig4_panelB, clear
su pvalue coeff, d
drop if coeff==.

sort group_order coeff
capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 6 "Politics" 18 "Geo/Demo" 30 "Economy" 42 "China" 
label val no example

twoway (rcap cit cib no if group=="Politics", lcolor(black)) ///
(scatter coeff no if group=="Politics", msymbol(x) mcolor(black) ///
xtick(6 18 30 42)  xlabel(6 18 30 42, alternate  valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Geo/Demo", lcolor(dkgreen)) ///
(scatter coeff no if group=="Geo/Demo", msymbol(x) mcolor(dkgreen)) ///
(rcap cit cib no if group=="Economy", lcolor(navy)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(navy)) ///
(rcap cit cib no if group=="China", lcolor(red)) ///
(scatter coeff no if group=="China", msymbol(x) mcolor(red) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates")) name(Graph, replace))
graph save Graph "F4_PanelB", replace
graph export "F4_PanelB.jpg", as(jpg) quality(100) name("Graph") replace





                     ***** RESULTS IN APPENDIX *****
																	 
*** FIGURE A1: DISTRIBUTION OF YEARS TO ELECTION FOR LEADERS WHO CAN AND CANNOT RUN ***

use covid19_replication.dta, clear

** Panel A: Any Term Limit **

twoway (kdensity electionproximity_yrs if canrun & maxconsecutiveterms !=.) (kdensity electionproximity_yrs if !canrun & maxconsecutiveterms !=.), title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small))) ytitle("") xtitle("Years to Next Election", height(7)) ylab(.05(0.05).25, nogrid) legend(order(1 "Can Run" 2 "Cannot Run")) graphregion(color(white)) bgcolor(white)
graph save Graph "FA1_PanelA", replace
graph export "FA1_PanelA.jpg", as(jpg) quality(100) name("Graph") replace

ksmirnov electionproximity_yrs, by(canrun)


** Panel B: 2-Term Limit **

twoway (kdensity electionproximity_yrs if canrun & maxconsecutiveterms == 2) (kdensity electionproximity_yrs if !canrun & maxconsecutiveterms == 2), title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small))) ytitle("") xtitle("Years to Next Election", height(7)) ylab(.05(0.05).25, nogrid) legend(order(1 "Can Run" 2 "Cannot Run")) graphregion(color(white)) bgcolor(white)
graph save Graph "FA1_PanelB", replace
graph export "FA1_PanelB.jpg", as(jpg) quality(100) name("Graph") replace

ksmirnov electionproximity_yrs if maxconsecutiveterms == 2, by(canrun)



*** TABLE A2: ELECTORAL CONCERNS AND TIMING OF COVID-19 OUTBREAK ***

* Column 1: OLS, Any Limit *
reg timetocase1 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
outreg2 using TA2, addtext(Sample, Any Limit) nocon tex replace

* Column 2: OLS, Two-Term Limit *
reg timetocase1 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
outreg2 using TA2, addtext(Sample, Any Limit) nocon tex append

* Column 1: Negative Binomial, Any Limit *
nbreg timetocase1 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
outreg2 using TA2, addtext(Sample, Any Limit) nocon tex append

* Column 2: Negative Binomial, Two-Term Limit *
nbreg timetocase1 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
outreg2 using TA2, addtext(Sample, Any Limit) nocon tex append



*** FIGURE A2: BALANCE TESTS, POLITICAL COVARIATES ***

** Panel A: Any Term Limit **

foreach var of varlist Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui est store `var'
}

coefplot Z_incumbentage, bylabel(Leader's Age) || Z_incumbentpartyleftright, bylabel(Ideology) || Z_margvic, bylabel(Margin of Victory) || Z_fh_ipolity2, bylabel(Polity Score) || Z_p_durable, bylabel(Regime Duration) || Z_cspf_sfi, bylabel(State Fragility) || Z_gpi_gpi, bylabel(Global Peace Index) || Z_bci_bci, bylabel(Corruption) || Z_decentralizationindex, bylabel(DI: Overall) || Z_politicaldecentrindex, bylabel(DI: Political) || Z_admindecentrindex, bylabel(DI: Administrative) || Z_fiscaldecentrindex, bylabel(DI: Fiscal) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap))
graph save Graph "FA2_PanelA.gph", replace
graph export "FA2_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

foreach var of varlist Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi  Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui est store `var'
}

coefplot Z_incumbentage, bylabel(Leader's Age) || Z_incumbentpartyleftright, bylabel(Ideology) || Z_margvic, bylabel(Margin of Victory) || Z_fh_ipolity2, bylabel(Polity Score) || Z_p_durable, bylabel(Regime Duration) || Z_cspf_sfi, bylabel(State Fragility) || Z_gpi_gpi, bylabel(Global Peace Index) || Z_bci_bci, bylabel(Corruption) || Z_decentralizationindex, bylabel(DI: Overall) || Z_politicaldecentrindex, bylabel(DI: Political) || Z_admindecentrindex, bylabel(DI: Administrative) || Z_fiscaldecentrindex, bylabel(DI: Fiscal) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap))
graph save Graph "FA2_PanelB.gph", replace
graph export "FA2_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE A3: BALANCE TESTS, GEOGRAPHIC & DEMOGRAPHIC COVARIATES ***

** Panel A: Any Term Limit **

foreach var of varlist Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui est store `var'
}

coefplot Z_lp_lat_abst, bylabel(Latitude) || Z_wdi_area, bylabel(Land Area) || Z_wdi_araland, bylabel(% Arable Land) || Z_wdi_pop, bylabel(Population) || Z_wdi_popden, bylabel(Population Density) || Z_wdi_popurb, bylabel(Urban Population (% Total)) || Z_wdi_pop14, bylabel(% Younger than 14) || Z_wdi_pop1564, bylabel(% Aged 15 to 64) || Z_wdi_pop65, bylabel(% Older than 65) || Z_wdi_lifexp, bylabel(Life Expectancy) || Z_wdi_death, bylabel(Death Rate (x 1000 people)) || Z_wdi_agedr, bylabel(Age Dependency Ratio) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA3_PanelA.gph", replace
graph export "FA3_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

foreach var of varlist Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui est store `var'
}

coefplot Z_lp_lat_abst, bylabel(Latitude) || Z_wdi_area, bylabel(Land Area) || Z_wdi_araland, bylabel(% Arable Land) || Z_wdi_pop, bylabel(Population) || Z_wdi_popden, bylabel(Population Density) || Z_wdi_popurb, bylabel(Urban Population (% Total)) || Z_wdi_pop14, bylabel(% Younger than 14) || Z_wdi_pop1564, bylabel(% Aged 15 to 64) || Z_wdi_pop65, bylabel(% Older than 65) || Z_wdi_lifexp, bylabel(Life Expectancy) || Z_wdi_death, bylabel(Death Rate (x 1000 people)) || Z_wdi_agedr, bylabel(Age Dependency Ratio) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA3_PanelB.gph", replace
graph export "FA3_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE A4: BALANCE TESTS, ECONOMIC COVARIATES ***

** Panel A: Any Term Limit **

foreach var of varlist Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui est store `var'
}

coefplot Z_wdi_gdpcappppcon2011, bylabel(GDP Per Capita) || Z_ffp_ued, bylabel(Uneven Development) || Z_wdi_trade, bylabel(Trade (% GDP)) || Z_fi_ftradeint, bylabel(International Trade Freedom) || Z_wdi_fdiout, bylabel(Outward FDIs (% GDP)) || Z_wdi_fdiin, bylabel(Inward FDIs (% GDP)) || Z_wdi_unempilo, bylabel(% Unemployed) || Z_wdi_semp, bylabel(% Self-Employed) || Z_wdi_empagr, bylabel(% Employed in Agriculture) || Z_wdi_empind, bylabel(% Employed in Industry) || Z_wdi_empser, bylabel(% Employed in Services) || Z_undp_hdi, bylabel(Human Development Index) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA4_PanelA.gph", replace
graph export "FA4_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

foreach var of varlist Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui est store `var'
}

coefplot Z_wdi_gdpcappppcon2011, bylabel(GDP Per Capita) || Z_ffp_ued, bylabel(Uneven Development) || Z_wdi_trade, bylabel(Trade (% GDP)) || Z_fi_ftradeint, bylabel(International Trade Freedom) || Z_wdi_fdiout, bylabel(Outward FDIs (% GDP)) || Z_wdi_fdiin, bylabel(Inward FDIs (% GDP)) || Z_wdi_unempilo, bylabel(% Unemployed) || Z_wdi_semp, bylabel(% Self-Employed) || Z_wdi_empagr, bylabel(% Employed in Agriculture) || Z_wdi_empind, bylabel(% Employed in Industry) || Z_wdi_empser, bylabel(% Employed in Services) || Z_undp_hdi, bylabel(Human Development Index) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA4_PanelB.gph", replace
graph export "FA4_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE A5: BALANCE TESTS, CONNECTEDNESS TO CHINA ***

** Panel A: Any Term Limit **

foreach var of varlist Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui est store `var'
}

coefplot Z_dist, bylabel(Distance to China) || Z_inflights_totairports, bylabel(Direct Routes from China) || inflights_yes, bylabel(Has Direct Route from China) || inflights_wuhan_yes, bylabel(Has Direct Flight from Wuhan) || Z_totaltradevalue2018, bylabel(Value of Trade w/ China) || Z_importvalue2018, bylabel(Import from China) || Z_exportvalue2018, bylabel(Export to China) || Z_fdifromchinadec2018, bylabel(FDIs from China) || Z_fdifromchinaavg, bylabel(Average FDIs from China) || Z_proj_turnover2018, bylabel(Contracts w/ China: Turnover) || Z_proj_displabor2018, bylabel(Contracts w/ China: Labor) || Z_proj_persabroad2018, bylabel(Chinese Overseas Workers) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA5_PanelA.gph", replace
graph export "FA5_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

foreach var of varlist Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 {

qui reg `var' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui est store `var'
}

coefplot Z_dist, bylabel(Distance to China) || Z_inflights_totairports, bylabel(Direct Routes from China) || inflights_yes, bylabel(Has Direct Route from China) || inflights_wuhan_yes, bylabel(Has Direct Flight from Wuhan) || Z_totaltradevalue2018, bylabel(Value of Trade w/ China) || Z_importvalue2018, bylabel(Import from China) || Z_exportvalue2018, bylabel(Export to China) || Z_fdifromchinadec2018, bylabel(FDIs from China) || Z_fdifromchinaavg, bylabel(Average FDIs from China) || Z_proj_turnover2018, bylabel(Contracts w/ China: Turnover) || Z_proj_displabor2018, bylabel(Contracts w/ China: Labor) || Z_proj_persabroad2018, bylabel(Chinese Overseas Workers) ||, drop (_cons) xline(0) graphregion(color(white)) ylab(, nogrid) byopts(compact cols(3)) ciopts(recast(rcap)) 
graph save Graph "FA5_PanelB.gph", replace
graph export "FA5_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE A6: CONTROLLING FOR COVARIATES INTERACTED WITH PROXIMITY TO THE NEXT ELECTION ***

** Panel A: Any Term Limit **

* Prepare empty data set to store results *

clear all
set obs 62
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Politics"
g id = _n
replace group = "Geo/Demo" if id > 12 & id < 25
replace group = "Economy" if id > 24 & id < 37  
replace group = "China" if id > 36 & id < 49
replace group = "Regions" if id > 48
gen group_order = 1
replace group_order = 2 if group == "Geo/Demo"
replace group_order = 3 if group == "Economy"
replace group_order = 4 if group == "China"
replace group_order = 5 if group == "Regions"
drop id 
save figA6_panelA.dta, replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 northafrica eastafrica middleafrica southernafrica westafrica centralamerica southamerica centralasia eastasia southeastasia southasia westasia easterneurope westerneurope {
    
preserve	
eststo `var': reg SI_1 canrun c.electionproximity_yrs##c.`var' electionproximity_yrs_canrun, vce(robust)
sleep 1000
use figA6_panelA.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save figA6_panelA.dta, replace
restore			
}

* Producing the plot *

use figA6_panelA.dta, clear
su pvalue coeff, d
drop if coeff==.

sort group_order coeff
capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 6 "Politics" 18 "Geo/Demo" 30 "Economy" 42 "China" 55 "Regions"
label val no example

twoway (rcap cit cib no if group=="Politics", lcolor(black)) ///
(scatter coeff no if group=="Politics", msymbol(x) mcolor(black) ///
xtick(6 18 30 42 55)  xlabel(6 18 30 42 55, alternate  valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Geo/Demo", lcolor(dkgreen)) ///
(scatter coeff no if group=="Geo/Demo", msymbol(x) mcolor(dkgreen)) ///
(rcap cit cib no if group=="Economy", lcolor(navy)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(navy)) ///
(rcap cit cib no if group=="China", lcolor(red)) ///
(scatter coeff no if group=="China", msymbol(x) mcolor(red)) ///
(rcap cit cib no if group=="Regions", lcolor(purple)) ///
(scatter coeff no if group=="Regions", msymbol(x) mcolor(purple) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates"))  name(Graph, replace))
graph save Graph "FA6_PanelA", replace
graph export "FA6_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

* Prepare empty data set to store results *

clear all
set obs 60
g var = "."
g coeff = . 
g se = . 
g pvalue = . 
g group = "Politics"
g id = _n
replace group = "Geo/Demo" if id > 12 & id < 25
replace group = "Economy" if id > 24 & id < 37  
replace group = "China" if id > 36 & id < 49
replace group = "Regions" if id > 48
gen group_order = 1
replace group_order = 2 if group == "Geo/Demo"
replace group_order = 3 if group == "Economy"
replace group_order = 4 if group == "China"
replace group_order = 5 if group == "Regions"
drop id 
save figA6_panelB.dta  , replace

* Get main data set and run regressions, storing results *

local i = 1

use covid19_replication.dta, clear

foreach var in Z_incumbentage Z_incumbentpartyleftright Z_margvic Z_fh_ipolity2 Z_p_durable Z_cspf_sfi Z_gpi_gpi Z_bci_bci Z_politicaldecentrindex Z_admindecentrindex Z_decentralizationindex Z_fiscaldecentrindex Z_lp_lat_abst Z_wdi_area Z_wdi_araland Z_wdi_pop Z_wdi_popden Z_wdi_popurb Z_wdi_pop14 Z_wdi_pop1564 Z_wdi_pop65 Z_wdi_lifexp Z_wdi_death Z_wdi_agedr Z_wdi_gdpcappppcon2011 Z_ffp_ued Z_wdi_trade Z_fi_ftradeint Z_wdi_fdiout Z_wdi_fdiin Z_wdi_unempilo Z_wdi_semp Z_wdi_empagr Z_wdi_empind Z_wdi_empser Z_undp_hdi Z_dist Z_inflights_totairports inflights_yes inflights_wuhan_yes Z_totaltradevalue2018 Z_importvalue2018 Z_exportvalue2018 Z_fdifromchinadec2018 Z_fdifromchinaavg Z_proj_turnover2018 Z_proj_displabor2018 Z_proj_persabroad2018 northafrica eastafrica middleafrica southernafrica westafrica southamerica centralasia southeastasia southasia westasia easterneurope {
    
preserve	
eststo `var': reg SI_1 canrun c.electionproximity_yrs##c.`var' electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
sleep 1000
use figA6_panelB.dta, clear
replace var = "`var'" in `i' 
replace coeff = _b[electionproximity_yrs_canrun] in `i' 	
replace se = _se[electionproximity_yrs_canrun] in `i' 	
replace pvalue = (2 * ttail(e(df_r), abs(_b[electionproximity_yrs_canrun]/_se[electionproximity_yrs_canrun]))) in `i'
local i = `i'+ 1
save figA6_panelB.dta, replace
restore			
}

* Producing the plot *

use figA6_panelB.dta, clear
su pvalue coeff, d
drop if coeff==.

sort group_order coeff
capture drop no
g no=_n 

g cib = coeff - 1.96*se
g cit = coeff + 1.96*se

label define example 6 "Politics" 18 "Geo/Demo" 30 "Economy" 42 "China" 54 "Regions"
label val no example

twoway (rcap cit cib no if group=="Politics", lcolor(black)) ///
(scatter coeff no if group=="Politics", msymbol(x) mcolor(black) ///
xtick(6 18 30 42 54)  xlabel(6 18 30 42 54, alternate  valuelabel) xtitle("") ///
ytitle("Normalized Effect Size", height(7)) yline(0) graphregion(color(white)) ///
ylab(, nogrid) title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small)))) ///
(rcap cit cib no if group=="Geo/Demo", lcolor(dkgreen)) ///
(scatter coeff no if group=="Geo/Demo", msymbol(x) mcolor(dkgreen)) ///
(rcap cit cib no if group=="Economy", lcolor(navy)) ///
(scatter coeff no if group=="Economy", msymbol(x) mcolor(navy)) ///
(rcap cit cib no if group=="China", lcolor(red)) ///
(scatter coeff no if group=="China", msymbol(x) mcolor(red)) ///
(rcap cit cib no if group=="Regions", lcolor(purple)) ///
(scatter coeff no if group=="Regions", msymbol(x) mcolor(purple) ///
legend(order(1 "95% Confidence Interval" 2 "Point Estimates"))  name(Graph, replace))
graph save Graph "FA6_PanelB", replace
graph export "FA6_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** TABLE A3: CONTROLLING FOR TERM LENGTH AS A POTENTIAL CONFOUNDER ***

use covid19_replication.dta, clear

** Column 1: Any Term Limit **

reg SI_1 c.canrun##c.termlength electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
outreg2 using TA3, addtext(Sample, Any Limit) nocon nor2 tex replace

** Column 2: 2-Term Limit **

reg SI_1 c.canrun##c.termlength electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
outreg2 using TA3, addtext(Sample, Any Limit) nocon nor2 tex append



*** FIGURE A7: ROBUSTNESS TO DIFFERENT PERIODS OF OBSERVATION ***

use covid19_replication.dta, clear

** Panel A: Any Term Limit **

forval num = 22008/22064 {
	
qui reg SP_`num' canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui est store c`num'
}

coefplot (c22008) (c22009) (c22010) (c22011) (c22012) (c22013) (c22014) (c22015) (c22016) (c22017) (c22018) (c22019) (c22020) (c22021) (c22022) (c22023) (c22024) (c22025) (c22026) (c22027)(c22028) (c22029) (c22030) (c22031) (c22032) (c22033) (c22034) (c22035) (c22036) (c22037) (c22038) (c22039) (c22040) (c22041) (c22042) (c22043) (c22044) (c22045) (c22046) (c22047) (c22048) (c22049) (c22050) (c22051) (c22052) (c22053) (c22054) (c22055) (c22056) (c22057) (c22058) (c22059) (c22060) (c22061) (c22062) (c22063) (c22064), vertical yline(0) ytitle(Effect Size, height(7)) xtitle(End of Observation Period - from April 3rd to May29th, height(7)) msymbol(x) mcolor(navy) ciopts(recast(rcap) color(navy)) keep(electionproximity_yrs_canrun) legend(off) saving(electionproximity_yrs_canrun, replace) xla(, nolabels) xla(, notick) ylab(, nogrid) title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small))) graphregion(color(white)) 
graph save Graph "FA7_PanelA", replace
graph export "FA7_PanelA.jpg", as(jpg) quality(100) name("Graph") replace


** Panel B: 2-Term Limit **

forval num = 22008/22064 {
	
qui reg SP_`num' canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui est store c`num'
}

coefplot (c22008) (c22009) (c22010) (c22011) (c22012) (c22013) (c22014) (c22015) (c22016) (c22017) (c22018) (c22019) (c22020) (c22021) (c22022) (c22023) (c22024) (c22025) (c22026) (c22027)(c22028) (c22029) (c22030) (c22031) (c22032) (c22033) (c22034) (c22035) (c22036) (c22037) (c22038) (c22039) (c22040) (c22041) (c22042) (c22043) (c22044) (c22045) (c22046) (c22047) (c22048) (c22049) (c22050) (c22051) (c22052) (c22053) (c22054) (c22055) (c22056) (c22057) (c22058) (c22059) (c22060) (c22061) (c22062) (c22063) (c22064), vertical yline(0) ytitle(Effect Size, height(7)) xtitle(End of Observation Period - from April 3rd to May29th, height(7)) msymbol(x) mcolor(navy) ciopts(recast(rcap) color(navy)) keep(electionproximity_yrs_canrun) legend(off) saving(electionproximity_yrs_canrun, replace) xla(, nolabels) xla(, notick) ylab(, nogrid) title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small))) graphregion(color(white)) 
graph save Graph "FA7_PanelB", replace
graph export "FA7_PanelB.jpg", as(jpg) quality(100) name("Graph") replace



*** FIGURE A8: LEAVE-ONE-OUT TESTS, COUNTRIES ***

** Panel A: Any Term Limit **

qui reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun, vce(robust)
qui gen in_panelA = 0
qui replace in_panelA = 1 if e(sample)==1

preserve
keep if in_panelA == 1
qui g country_id = _n

forvalues i = 1(1)65 {
    
reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun if country_id !=`i', vce(robust)
qui est store c`i'
sleep 1000	
}

coefplot (c1) (c2) (c3) (c4) (c5) (c6) (c7) (c8) (c9) (c10) ///
(c11) (c12) (c13) (c14) (c15) (c16) (c17) (c18) (c19) (c20) ///
(c21) (c22) (c23) (c24) (c25) (c26) (c27) (c28) (c29) (c30) ///
(c31) (c32) (c33) (c34) (c35) (c36) (c37) (c38) (c39) (c40) ///
(c41) (c42) (c43) (c44) (c45) (c46) (c47) (c48) (c49) (c50) ///
(c51) (c52) (c53) (c54) (c55) (c56) (c57) (c58) (c59) (c60) ///
(c61) (c62) (c63) (c64) (c65), ///
vertical yline(0) ytitle(Effect Size, height(7)) xtitle("", height(7)) msymbol(x) ///
mcolor(navy) ciopts(recast(rcap) color(navy)) keep(electionproximity_yrs_canrun) ///
title(Panel A: Any Term Limit, color(black) height(3) tstyle(size(medium small))) ///
graphregion(color(white)) saving(electionproximity_yrs_canrun, replace) ///
legend(off) xla(, nolabels) xla(, notick) ylab(, nogrid) 
graph save Graph "FA8_PanelA", replace
graph export "FA8_PanelA.jpg", as(jpg) quality(100) name("Graph") replace
restore


** Panel B: 2-Term Limit **

qui reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun if maxconsecutiveterms == 2, vce(robust)
qui gen in_panelB = 0
qui replace in_panelB = 1 if e(sample)==1

preserve
keep if in_panelB == 1
qui g country_id = _n

forvalues i = 1(1)50 {
    
reg SI_1 canrun electionproximity_yrs electionproximity_yrs_canrun if country_id !=`i', vce(robust)
qui est store c`i'
sleep 1000	
}

coefplot (c1) (c2) (c3) (c4) (c5) (c6) (c7) (c8) (c9) (c10) (c11) ///
(c12) (c13) (c14) (c15) (c16) (c17) (c18) (c19) (c20) (c21) (c22) ///
(c23) (c24) (c25) (c26) (c27) (c28) (c29) (c30) (c31) (c32) (c33) ///
(c34) (c35) (c36) (c37) (c38) (c39) (c40) (c41) (c42) (c43) (c44) ///
(c45) (c46) (c47) (c48) (c49) (c50), ///
vertical yline(0) ytitle(Effect Size, height(7)) xtitle("", height(7)) msymbol(x) ///
mcolor(navy) ciopts(recast(rcap) color(navy)) keep(electionproximity_yrs_canrun) ///
title(Panel B: Two-Term Limit, color(black) height(3) tstyle(size(medium small))) ///
graphregion(color(white)) saving(electionproximity_yrs_canrun, replace) ///
legend(off) xla(, nolabels) xla(, notick) ylab(, nogrid) 
graph save Graph "FA8_PanelB", replace
graph export "FA8_PanelB.jpg", as(jpg) quality(100) name("Graph") replace
restore



*** FIGURE A9: RANDOMIZATION INFERENCE, INDICATOR FOR RE-ELIGIBLE LEADER ***

cd "C:\Users\massi\Dropbox\COVID Response\Generate Data"
clear all
set obs 1000
g iter = .
g coeff = . 
g se = . 
g t = . 
save figA9.dta, replace

use "C:\Users\massi\Dropbox\COVID Response\Data\foranalysis.dta", clear
cd "C:\Users\massi\Dropbox\COVID Response\Generate Data"

keep if maxconsecutiveterms !=.

set seed 12345 

local i = 1
 
forvalues j = 1/1000 {
    
* Assign random numbers to the observations and rank them from the smallest to the largest
gen random_number_`j' = uniform()
egen ordering_`j' = rank(random_number_`j')
    
* Assign observations to control & treatment group based on their ranks 
gen canrun_`j' = .  
replace canrun_`j' = 0 if ordering_`j' <= 65/2.25
replace canrun_`j' = 1 if canrun_`j'==.

* Recreate interaction *
gen ep_cr_`j' =.
replace ep_cr_`j' = canrun_`j' * electionproximity_yrs

* Run regressions and store results *
preserve
eststo it_`j': reg SI_1 canrun_`j' electionproximity_yrs ep_cr_`j', vce(robust)
sleep 1000
use figA9.dta, clear
replace iter = `j' in `i' 
replace coeff = _b[ep_cr_`j'] in `i' 	
replace se = _se[ep_cr_`j'] in `i' 	
replace t = _b[ep_cr_`j']/_se[ep_cr_`j'] in `i' 	
local i = `i'+ 1
sleep 1000
save figA9.dta, replace
estimates drop it_`j'
restore			
}

* Producing the plot *

use figA9.dta, clear
kdensity t, xline(-2.65) xline(-2.331) xline(-1.655) xline(-1.355)
graph save Graph "FA9", replace
graph export "FA9.jpg", as(jpg) quality(100) name("Graph") replace